/*
    MinMax.h - Basic templates for numbers
    License: BSD
*/
#ifndef MINMAX_H_INCLUDED
#define	MINMAX_H_INCLUDED

template<typename T>
T& t_min( const T& lhs, const T& rhs )
{
    return (lhs<rhs) ? lhs : rhs;
}

template<typename T>
T& t_max( const T& lhs, const T& rhs )
{
    return (lhs>rhs) ? lhs : rhs;
}

template<typename T>
T t_clamp( const T& value, const T& min, const T& max )
{
    return t_max( min, t_min(value, max) );
}

template<typename T>
void t_swap( const T& lhs, const T& rhs )
{
    T tmp = rhs;
    rhs   = lhs;
    lhs   = tmp;
}

#endif
